var t = getApp();

Page({
    data: {
        goodshow: !1,
        tapStart: !1,
        show: !1,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        list: [],
        language: {}
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        }), this.getList();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    toGoods: function(t) {
        var a = t.currentTarget.dataset.goodid;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    toIndex: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageE/managementIndex/managementIndex?producer_id=" + a
        });
    },
    getList: function(a) {
        var o = this, e = this, s = t.getNetAddresss("plugin.producer.frontend.producer.getList");
        t._getNetWork({
            url: s,
            data: {},
            success: function(t) {
                var a = t.data;
                1 == a.result ? (o.setData({
                    isLoadMore: !0,
                    total_page: a.data.data.last_page,
                    list: a.data.data.data
                }), e.data.list.forEach(function(t, a) {
                    t.goods_list.length > 8 && (t.goodshow = !0, t.goods_list = t.goods_list.slice(0, 8));
                }), e.setData({
                    list: e.data.list
                }), o.data.total_page || o.setData({
                    total_page: 0
                })) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var o = this.data.page + 1;
            this.setData({
                page: o
            });
            var e = t.getNetAddresss("plugin.producer.frontend.producer.getList");
            t._getNetWork({
                url: e,
                data: {},
                success: function(t) {
                    var o = t.data;
                    if (1 == o.result) {
                        var e = o.data.data.data.concat(a.data.list);
                        a.setData({
                            list: e
                        }), that.data.list.forEach(function(t, a) {
                            t.goods_list.length > 8 && (t.goodshow = !0, t.goods_list = t.goods_list.slice(0, 8));
                        }), that.setData({
                            list: that.data.list
                        });
                    } else {
                        wx.showToast({
                            title: o.msg,
                            icon: "none"
                        });
                        var s = a.data.page - 1;
                        a.setData({
                            page: s,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});